﻿
@{
    ViewData["Title"] = "修改账号";
    ViewBag.nav = "account";
}

<div id="app">

    <h2>修改账号</h2>

    <form class="form-horizontal" style="max-width:800px;">
        <div class="form-group">
            <label class="col-sm-2 control-label">新账号</label>
            <div class="col-sm-10">
                <input class="form-control" v-model.trim="account" placeholder="新账号">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">新密码</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" v-model.trim="password" placeholder="新密码">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" @@click="submit" class="btn btn-primary">确定</button>
            </div>
        </div>
    </form>
</div>

@section scripts{

    <script>
        var app = new Vue({
            el: "#app",
            data: {
                account: '',
                password: '',
            },
            methods: {
                submit: function () {
                    if (this.account == '') {
                        alert('账号不能为空');
                        return;
                    }
                    if (this.password == '') {
                        alert('密码不能为空');
                        return;
                    }
                    $.post('doUpdateAccount', { account: this.account, password: this.password }, function (flag) {
                        if (flag > 0) {
                            alert("修改成功");
                            location.reload();
                        } else {
                            alert("修改失败");
                        }
                    });
                }
            }
        })
    </script>
}